package dto

import (
	"gitee.com/zhoulvvv/my_go_gateway/public"
	"github.com/gin-gonic/gin"
)

// 服务请求列表
type ServiceListInput struct {
	Info     string `json:"info" form:"info" comment:"关键词搜索" example:"" validate:""`                    // 关键词搜索
	PageNo   int    `json:"page_no" form:"page_no" comment:"页数" example:"1" validate:"required"`        // 页数
	PageSize int    `json:"page_size" form:"page_size" comment:"每页数量" example:"20" validate:"required"` // 每页数量
}

// 服务删除
type ServiceDeleteInput struct {
	ID int `json:"id" form:"id" comment:"服务Id" example:"56" validate:"required"` // id主键
}

// 服务详情
type ServiceDetailInput struct {
	ID int `json:"id" form:"id" comment:"服务Id" example:"56" validate:"required"` // id主键
}

// 服务统计
type ServiceStatInput struct {
	ID int `json:"id" form:"id" comment:"服务Id" example:"56" validate:"required"` // id主键
}

// 服务列表响应的每一条数据
type ServiceListItemOutput struct {
	ID          int64  `json:"id" form:"id"`                     // id主键
	ServiceName string `json:"service_name" form:"service_name"` // 服务名称
	ServiceDesc string `json:"service_desc" form:"service_desc"` // 服务描述
	LoadType    int    `json:"load_type" form:"load_type"`       // 服务类型
	ServiceAddr string `json:"service_addr" form:"service_addr"` // 服务地址
	Qps         int64  `json:"qps" form:"qps"`                   // qps
	Qpd         int64  `json:"qpd" form:"qpd"`                   // 日请求数
	TotalNode   int    `json:"total_node" form:"total_node"`     // 节点数
}

// 服务列表响应
type ServiceListOutput struct {
	Total int                     `json:"total" form:"total" comment:"总数"`   // 总数
	List  []ServiceListItemOutput `json:"list" form:"list" comment:"服务列表数据"` // 服务列表数据
}

// 服务流量统计
type ServiceStatOutput struct {
	Today     []int64 `json:"today" form:"today" comment:"今日服务流浪统计"`         // 今日服务流浪统计
	Yesterday []int64 `json:"yesterday" form:"yesterday" comment:"昨日服务流浪统计"` // 昨日服务流浪统计
}

// HTTP服务修改
type ServiceUpdateHTTPInput struct {
	Id                     int    `json:"id" form:"id" comment:"服务id" example:"62" validate:"required"`                                                            // id主键
	ServiceName            string `json:"service_name" form:"service_name" comment:"服务名称" example:"test_http_service_indb" validate:"required,valid_service_name"` // 服务名称
	ServiceDesc            string `json:"service_desc" form:"service_desc" comment:"服务描述" example:"test_http_service_indb" validate:"required,max=255,min=0"`      // 服务描述
	RuleType               int    `json:"rule_type" form:"rule_type" comment:"接入类型" example:"0" validate:"max=1,min=0"`                                            // 接入类型
	Rule                   string `json:"rule" form:"rule" comment:"接入路径" example:"/test_http_service_indb" validate:"required,valid_rule"`                        // 接入路径
	NeedHttps              int    `json:"need_https" form:"need_https" comment:"支持https" example:"0" validate:"max=1,min=0"`                                       // 支持https
	NeedStripUri           int    `json:"need_strip_uri" form:"need_strip_uri" comment:"支持strip_uri" example:"0" validate:"max=1,min=0"`                           // 支持strip_uri
	NeedWebsocket          int    `json:"need_websocket" form:"need_websocket" comment:"支持need_websocket" example:"0" validate:"max=1,min=0"`                      // 支持need_websocket
	UrlRewrite             string `json:"url_rewrite" form:"url_rewrite" comment:"URL重写" example:"" validate:"valid_url_rewrite"`                                  // URL重写
	HeaderTransfor         string `json:"header_transfor" form:"header_transfor" comment:"Header转换" example:"" validate:"valid_header_transfor"`                   // Header转换
	OpenAuth               int    `json:"open_auth" form:"open_auth" comment:"开启验证" example:"0" validate:"max=1,min=0"`                                            // 开启验证
	WhiteList              string `json:"white_list" form:"white_list" comment:"IP白名单" example:"" validate:""`                                                     // IP白名单
	BlackList              string `json:"black_list" form:"black_list" comment:"IP黑名单" example:"" validate:""`                                                     // IP黑名单
	ClientipFlowLimit      int    `json:"clientip_flow_limit" form:"clientip_flow_limit" comment:"客户端限流" example:"0" validate:"min=0"`                             // 客户端限流
	ServiceFlowLimit       int    `json:"service_flow_limit" form:"service_flow_limit" comment:"服务端限流" example:"0" validate:"min=0"`                               // 服务端限流
	RoundType              int    `json:"round_type" form:"round_type" comment:"轮询方式" example:"0" validate:"max=3,min=0"`                                          // 轮询方式
	IpList                 string `json:"ip_list" form:"ip_list" comment:"IP列表" example:"127.0.0.1:80" validate:"required,valid_ip_list"`                          // IP列表
	WeightList             string `json:"weight_list" form:"weight_list" comment:"权重列表" example:"50" validate:"required,valid_weight_list"`                        // 权重列表
	UpstreamConnectTimeout int    `json:"upstream_connect_timeout" form:"upstream_connect_timeout" comment:"建立连接超时" example:"0" validate:"min=0"`                  // 建立连接超时
	UpstreamHeaderTimeout  int    `json:"upstream_header_timeout" form:"upstream_header_timeout" comment:"获取header超时" example:"0" validate:"min=0"`                // 获取header超时
	UpstreamIdleTimeout    int    `json:"upstream_idle_timeout" form:"upstream_idle_timeout" comment:"链接最大空闲时间" example:"0" validate:"min=0"`                      // 链接最大空闲时间
	UpstreamMaxIdle        int    `json:"upstream_max_idle" form:"upstream_max_idle" comment:"最大空闲链接数" example:"0" validate:"min=0"`                               // 最大空闲链接数
}

// GRPC 服务修改
type ServiceUpdateGRPCInput struct {
	Id                int    `json:"id" form:"id" comment:"服务id" example:"62" validate:"required"`                                            // id主键
	ServiceName       string `json:"service_name" form:"service_name" comment:"服务名称" example:"" validate:"required,valid_service_name"`       // 服务名称
	ServiceDesc       string `json:"service_desc" form:"service_desc" comment:"服务描述" example:"" validate:"required,max=255,min=0"`            // 服务描述
	Port              int    `json:"port" form:"port" comment:"端口，需要设置8001-8999范围" example:"8001" validate:"max=8999,min=8001"`               // 端口
	HeaderTransfor    string `json:"header_transfor" form:"header_transfor" comment:"metadata转换" example:"" validate:"valid_header_transfor"` // metadata转换
	OpenAuth          int    `json:"open_auth" form:"open_auth" comment:"开启验证" example:"0" validate:"max=1,min=0"`                            // 开启验证
	WhiteList         string `json:"white_list" form:"white_list" comment:"IP白名单" example:"" validate:""`                                     // IP白名单
	BlackList         string `json:"black_list" form:"black_list" comment:"IP黑名单" example:"" validate:""`                                     // IP黑名单
	WhiteHostName     string `json:"white_host_name" form:"white_host_name" comment:"白名单主机,号间隔" example:"" validate:""`                       // 白名单主机,号间隔
	ClientipFlowLimit int    `json:"clientip_flow_limit" form:"clientip_flow_limit" comment:"客户端限流" example:"0" validate:"min=0"`             // 客户端限流
	ServiceFlowLimit  int    `json:"service_flow_limit" form:"service_flow_limit" comment:"服务端限流" example:"0" validate:"min=0"`               // 服务端限流
	RoundType         int    `json:"round_type" form:"round_type" comment:"轮询方式" example:"0" validate:"max=3,min=0"`                          // 轮询方式
	IpList            string `json:"ip_list" form:"ip_list" comment:"IP列表" example:"" validate:"required,valid_ip_list"`                      // IP列表
	WeightList        string `json:"weight_list" form:"weight_list" comment:"权重列表" example:"" validate:"required,valid_weight_list"`          // 权重列表
	ForbidList        string `json:"forbid_list" form:"forbid_list" comment:"禁用IP列表" example:"" validate:"valid_forbid_list"`                 // 禁用IP列表
}

// TCP 服务修改
type ServiceUpdateTCPInput struct {
	Id                int    `json:"id" form:"id" comment:"服务id" example:"62" validate:"required"`                                      // id主键
	ServiceName       string `json:"service_name" form:"service_name" comment:"服务名称" example:"" validate:"required,valid_service_name"` // 服务名称
	ServiceDesc       string `json:"service_desc" form:"service_desc" comment:"服务描述" example:"" validate:"required,max=255,min=0"`      // 服务描述
	Port              int    `json:"port" form:"port" comment:"端口，需要设置8001-8999范围" example:"8001" validate:"max=8999,min=8001"`         // 端口
	OpenAuth          int    `json:"open_auth" form:"open_auth" comment:"开启验证" example:"0" validate:"max=1,min=0"`                      // 开启验证
	WhiteList         string `json:"white_list" form:"white_list" comment:"IP白名单" example:"" validate:""`                               // IP白名单
	BlackList         string `json:"black_list" form:"black_list" comment:"IP黑名单" example:"" validate:""`                               // IP黑名单
	WhiteHostName     string `json:"white_host_name" form:"white_host_name" comment:"白名单主机,号间隔" example:"" validate:""`                 // 白名单主机,号间隔
	ClientipFlowLimit int    `json:"clientip_flow_limit" form:"clientip_flow_limit" comment:"客户端限流" example:"0" validate:"min=0"`       // 客户端限流
	ServiceFlowLimit  int    `json:"service_flow_limit" form:"service_flow_limit" comment:"服务端限流" example:"0" validate:"min=0"`         // 服务端限流
	RoundType         int    `json:"round_type" form:"round_type" comment:"轮询方式" example:"0" validate:"max=3,min=0"`                    // 轮询方式
	IpList            string `json:"ip_list" form:"ip_list" comment:"IP列表" example:"" validate:"required,valid_ip_list"`                // IP列表
	WeightList        string `json:"weight_list" form:"weight_list" comment:"权重列表" example:"" validate:"required,valid_weight_list"`    // 权重列表
	ForbidList        string `json:"forbid_list" form:"forbid_list" comment:"禁用IP列表" example:"" validate:"valid_forbid_list"`           // 禁用IP列表
}

// HTTP 服务添加
type ServiceAddHTTPInput struct {
	ServiceName            string `json:"service_name" form:"service_name" comment:"服务名称" example:"" validate:"required,valid_service_name"`        // 服务名称
	ServiceDesc            string `json:"service_desc" form:"service_desc" comment:"服务描述" example:"" validate:"required,max=255,min=0"`             // 服务描述
	RuleType               int    `json:"rule_type" form:"rule_type" comment:"接入类型" example:"0" validate:"max=1,min=0"`                             // 接入类型
	Rule                   string `json:"rule" form:"rule" comment:"接入路径" example:"" validate:"required,valid_rule"`                                // 接入路径
	NeedHttps              int    `json:"need_https" form:"need_https" comment:"支持https" example:"0" validate:"max=1,min=0"`                        // 支持https
	NeedStripUri           int    `json:"need_strip_uri" form:"need_strip_uri" comment:"支持strip_uri" example:"0" validate:"max=1,min=0"`            // 支持strip_uri
	NeedWebsocket          int    `json:"need_websocket" form:"need_websocket" comment:"支持need_websocket" example:"0" validate:"max=1,min=0"`       // 支持need_websocket
	UrlRewrite             string `json:"url_rewrite" form:"url_rewrite" comment:"URL重写" example:"" validate:"valid_url_rewrite"`                   // URL重写
	HeaderTransfor         string `json:"header_transfor" form:"header_transfor" comment:"Header转换" example:"" validate:"valid_header_transfor"`    // Header转换
	OpenAuth               int    `json:"open_auth" form:"open_auth" comment:"开启验证" example:"0" validate:"max=1,min=0"`                             // 开启验证
	WhiteList              string `json:"white_list" form:"white_list" comment:"IP白名单" example:"" validate:""`                                      // IP白名单
	BlackList              string `json:"black_list" form:"black_list" comment:"IP黑名单" example:"" validate:""`                                      // IP黑名单
	ClientipFlowLimit      int    `json:"clientip_flow_limit" form:"clientip_flow_limit" comment:"客户端限流" example:"0" validate:"min=0"`              // 客户端限流
	ServiceFlowLimit       int    `json:"service_flow_limit" form:"service_flow_limit" comment:"服务端限流" example:"0" validate:"min=0"`                // 服务端限流
	RoundType              int    `json:"round_type" form:"round_type" comment:"轮询方式" example:"0" validate:"max=3,min=0"`                           // 轮询方式
	IpList                 string `json:"ip_list" form:"ip_list" comment:"IP列表" example:"" validate:"required,valid_ip_list"`                       // IP列表
	WeightList             string `json:"weight_list" form:"weight_list" comment:"权重列表" example:"" validate:"required,valid_weight_list"`           // 权重列表
	UpstreamConnectTimeout int    `json:"upstream_connect_timeout" form:"upstream_connect_timeout" comment:"建立连接超时" example:"0" validate:"min=0"`   // 建立连接超时
	UpstreamHeaderTimeout  int    `json:"upstream_header_timeout" form:"upstream_header_timeout" comment:"获取header超时" example:"0" validate:"min=0"` // 获取header超时
	UpstreamIdleTimeout    int    `json:"upstream_idle_timeout" form:"upstream_idle_timeout" comment:"链接最大空闲时间" example:"0" validate:"min=0"`       // 链接最大空闲时间
	UpstreamMaxIdle        int    `json:"upstream_max_idle" form:"upstream_max_idle" comment:"最大空闲链接数" example:"0" validate:"min=0"`                // 最大空闲链接数
}

// GRPC 服务添加
type ServiceAddGRPCInput struct {
	ServiceName       string `json:"service_name" form:"service_name" comment:"服务名称" example:"" validate:"required,valid_service_name"`       // 服务名称
	ServiceDesc       string `json:"service_desc" form:"service_desc" comment:"服务描述" example:"" validate:"required,max=255,min=0"`            // 服务描述
	Port              int    `json:"port" form:"port" comment:"端口，需要设置8001-8999范围" example:"8001" validate:"max=8999,min=8001"`               // 端口
	HeaderTransfor    string `json:"header_transfor" form:"header_transfor" comment:"metadata转换" example:"" validate:"valid_header_transfor"` // metadata转换
	OpenAuth          int    `json:"open_auth" form:"open_auth" comment:"开启验证" example:"0" validate:"max=1,min=0"`                            // 开启验证
	WhiteList         string `json:"white_list" form:"white_list" comment:"IP白名单" example:"" validate:""`                                     // IP白名单
	BlackList         string `json:"black_list" form:"black_list" comment:"IP黑名单" example:"" validate:""`                                     // IP黑名单
	WhiteHostName     string `json:"white_host_name" form:"white_host_name" comment:"白名单主机,号间隔" example:"" validate:""`                       // 白名单主机,号间隔
	ClientipFlowLimit int    `json:"clientip_flow_limit" form:"clientip_flow_limit" comment:"客户端限流" example:"0" validate:"min=0"`             // 客户端限流
	ServiceFlowLimit  int    `json:"service_flow_limit" form:"service_flow_limit" comment:"服务端限流" example:"0" validate:"min=0"`               // 服务端限流
	RoundType         int    `json:"round_type" form:"round_type" comment:"轮询方式" example:"0" validate:"max=3,min=0"`                          // 轮询方式
	IpList            string `json:"ip_list" form:"ip_list" comment:"IP列表" example:"" validate:"required,valid_ip_list"`                      // IP列表
	WeightList        string `json:"weight_list" form:"weight_list" comment:"权重列表" example:"" validate:"required,valid_weight_list"`          // 权重列表
	ForbidList        string `json:"forbid_list" form:"forbid_list" comment:"禁用IP列表" example:"" validate:"valid_forbid_list"`                 // 禁用IP列表
}

// TCP 服务添加
type ServiceAddTCPInput struct {
	ServiceName       string `json:"service_name" form:"service_name" comment:"服务名称" example:"" validate:"required,valid_service_name"` // 服务名称
	ServiceDesc       string `json:"service_desc" form:"service_desc" comment:"服务描述" example:"" validate:"required,max=255,min=0"`      // 服务描述
	Port              int    `json:"port" form:"port" comment:"端口，需要设置8001-8999范围" example:"8001" validate:"max=8999,min=8001"`         // 端口
	OpenAuth          int    `json:"open_auth" form:"open_auth" comment:"开启验证" example:"0" validate:"max=1,min=0"`                      // 开启验证
	WhiteList         string `json:"white_list" form:"white_list" comment:"IP白名单" example:"" validate:""`                               // IP白名单
	BlackList         string `json:"black_list" form:"black_list" comment:"IP黑名单" example:"" validate:""`                               // IP黑名单
	WhiteHostName     string `json:"white_host_name" form:"white_host_name" comment:"白名单主机,号间隔" example:"" validate:""`                 // 白名单主机,号间隔
	ClientipFlowLimit int    `json:"clientip_flow_limit" form:"clientip_flow_limit" comment:"客户端限流" example:"0" validate:"min=0"`       // 客户端限流
	ServiceFlowLimit  int    `json:"service_flow_limit" form:"service_flow_limit" comment:"服务端限流" example:"0" validate:"min=0"`         // 服务端限流
	RoundType         int    `json:"round_type" form:"round_type" comment:"轮询方式" example:"0" validate:"max=3,min=0"`                    // 轮询方式
	IpList            string `json:"ip_list" form:"ip_list" comment:"IP列表" example:"" validate:"required,valid_ip_list"`                // IP列表
	WeightList        string `json:"weight_list" form:"weight_list" comment:"权重列表" example:"" validate:"required,valid_weight_list"`    // 权重列表
	ForbidList        string `json:"forbid_list" form:"forbid_list" comment:"禁用IP列表" example:"" validate:"valid_forbid_list"`           // 禁用IP列表
}

func (param *ServiceUpdateHTTPInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}
func (param *ServiceUpdateGRPCInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}
func (param *ServiceUpdateTCPInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *ServiceAddHTTPInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *ServiceAddGRPCInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}
func (param *ServiceAddTCPInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *ServiceListInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *ServiceDeleteInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *ServiceDetailInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}
func (param *ServiceStatInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}
